package com.example.traning.mybatisplus.controller;

import com.example.traning.mybatisplus.dal.entity.Dept;
import com.example.traning.mybatisplus.dal.entity.Emp;
import com.example.traning.mybatisplus.dal.mapper.EmpMapper;
import com.example.traning.mybatisplus.service.IDeptService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * 注解 @NoArgsConstructor 生成无参构造方法
 * 注解 @AllArgsConstructor 生成全参构造方法
 * 注解 @RequiredArgsConstructor 生成所有加了 final的非基本类型参构造方法
 * @author Lei Yu
 * @since 2025-04-28
 */

@RequiredArgsConstructor
@RestController
@RequestMapping("/dept")
public class DeptController {

    private final IDeptService service;
    /**
     * localhost:8080/dept/10
     */
    @GetMapping("/{id}")
    public Dept getEmpById(@PathVariable(name = "id") Integer id) {
        return service.getById(id);
    }

}
